package es.ucm.fdi.healthpred.vista;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.JTextField;

/**
 * Campo de texto que selecciona todo su contenido al ganar el foco.
 * 
 * @since 1.0
 * 
 * @version 1.0
 * 
 * @author &Aacute;lvaro G&oacute;mez Porris
 * @author V&iacute;ctor L&oacute;pez Monte
 * @author Carlos Rodr&iacute;guez Colliga
 * 
 */
public class JTextFieldFoco extends JTextField {

	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	public JTextFieldFoco() {
		super();
		creaFoco();
	}

	/**
	 * @param texto
	 */
	public JTextFieldFoco(String texto) {
		super(texto);
		creaFoco();
	}

	/* PRIVADO */
	private void creaFoco() {
		addFocusListener(new FocusAdapter() {

			public void focusGained(FocusEvent e) {
				selectAll();
			}
		});
	}
}
